package com.jy.service;

import com.jy.dao.StudentMapper;
import com.jy.domain.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("studentService")
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

//    查询所有学生信息
    public List<Student> findAll(){
        return studentMapper.findAll();
    }

//    删除一个学生
    public int deleteStu(int sid){
        return studentMapper.deleteStudent(sid);
    }

//    查询学生个人信息
    public Student findById(int id){
        return studentMapper.findById(id);
    }

    //    通过学号查询学生个人信息
    public Student findBySId(int sid){
        return studentMapper.findBySId(sid);
    }

//    修改学生个人信息
    public int updateStudent(Student student){
        return studentMapper.updateStudent(student);
    }

//    添加学生
    public int saveStudent(Student student){
        return studentMapper.insertStudent(student);
    }

//    批量删除学生
    public int deleteStudents(int[] ints){
        return studentMapper.deleteStudents(ints);
    }

//    模糊查询通过学生名字
    public List<Student> findByNameLike(String s){
        String s1 = "%";
        String str = s1 + s +s1;
        return studentMapper.findByNameLike(str);
    }
}
